package com.pro.back.controller;

import com.pro.back.bean.Borrow;
import com.pro.back.bean.common.ApiRes;
import com.pro.back.bean.po.BorrowPO;
import com.pro.back.bean.po.ReturnParam;
import com.pro.back.service.BorrowService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * @Author: jingwenjuan
 * @Description:
 * @Date: 2025-04-19
 */
@RestController
@RequestMapping("/borrow")
public class BorrowController {

    @Autowired
    private BorrowService borrowService;

    @ApiOperation("查询所有的借还记录")
    @PostMapping("/selectAllBorrow")
    public ApiRes selectAllBorrow(@RequestBody BorrowPO po) {
        return borrowService.selectAllBorrow(po);
    }

    @ApiOperation("新增借出记录")
    @PostMapping("/insertBorrow")
    public ApiRes insertBorrow(@RequestBody Borrow borrow) throws ParseException {
        return borrowService.insertBorrow(borrow);
    }

    @ApiOperation("删除借出记录")
    @GetMapping("/delBorrow")
    public ApiRes delBorrow(Long id) throws ParseException {
        return borrowService.delBorrow(id);
    }

    @ApiOperation("归还设备")
    @PostMapping("/returnDevice")
    public ApiRes returnDevice(@RequestBody ReturnParam param) {
        return borrowService.returnDevice(param);
    }



}
